import { Component } from '@angular/core';
import {UserApiService} from "./core/api/user-api.service";
import {MenuItem, MessageService} from "primeng/api";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'frontend';

  menuItems: MenuItem[] = [
    {
      label: 'Login',
      routerLink: 'auth'
    },
    {
      label: 'Users',
      routerLink: 'admin/users'
    },
    {
      label: 'Add User',
      routerLink: 'admin/user/new'
    },
    {
      label: 'Logout',
      command: () => {
        this._userApiService.logout().subscribe({
          error: () => {
            this._messageService.add({severity: 'success', summary: 'Success', detail: 'User Update Successfully'});
          }
        });
      }
    }
  ];

  constructor(private readonly _userApiService: UserApiService,
              private readonly _messageService: MessageService) {
  }
}
